/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.meanzoft.m3d.resource;

import java.io.IOException;
import java.util.HashMap;
import org.meanzoft.m3d.texture.Texture;
import org.meanzoft.m3d.texture.TextureLoader;

/**
 *
 * @author Meanz
 */
public class ResourceManager {

    private static ResourceManager manager;

    public static ResourceManager getManager() {
        return manager;
    }
    /**
     * Pre
     */
    private TextureLoader textureLoader;
    /** Storage **/
    private HashMap<String, Texture> textures = new HashMap<String, Texture>();

    public ResourceManager() {
        textureLoader = new TextureLoader();
        manager = this;
    }

    public Texture getTexture(String textureId) {
        return textures.get(textureId);
    }

    public boolean loadTexture(String textureId, String textureFile) {
        try {
            Texture texture = textureLoader.getTexture(textureFile);
            textures.put(textureId, texture);
            return true;
        } catch (IOException iex) {
            iex.printStackTrace();
            return false;
        }
    }
    
    public Texture loadTexture(String textureId, int[] pixelsARGB, int imageWidth, int imageHeight) {
        return null;
    }    
    
    public TextureLoader getTextureLoader() {
        return textureLoader;
    }
}
